﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using PPAP.Model;
using System.Data.OracleClient;

namespace PPAP.DAO
{
    public class PARTDAO
    {
        public PARTDAO() { }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(PART model)
        {
            model.ID = DbHelperOra.GetMaxID("ID", "PART");
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into PART(");
            strSql.Append("ID,BDNTPARTNO,BDNTPARTNAME,BDNTREVISIONNO,BDNTREVISIONSTATUS,SUPPLIERID,CREATETIME,CREATEUSER,SUPPLIERPARTNO,SUPPLIERPARTNAME,COLOR,PLANTID,REASONFORSAMPLING,INTTIALSAMPLING,OTHERSAMPLES,QLEVEL,ELEVEL,MODIFICATIONSCOPE,REMARKS,ECUHWVERSIONNO,ECUSWVERSIONNO,PRESSPARTMOP,PRESSPARTCYCLE,PRESSPARTNEST,PRESSPARTREVISIONNUMBER,SUPPLIERADMIN)");
            strSql.Append(" values (");
            strSql.Append(":ID,:BDNTPARTNO,:BDNTPARTNAME,:BDNTREVISIONNO,:BDNTREVISIONSTATUS,:SUPPLIERID,:CREATETIME,:CREATEUSER,:SUPPLIERPARTNO,:SUPPLIERPARTNAME,:COLOR,:PLANTID,:REASONFORSAMPLING,:INTTIALSAMPLING,:OTHERSAMPLES,:QLEVEL,:ELEVEL,:MODIFICATIONSCOPE,:REMARKS,:ECUHWVERSIONNO,:ECUSWVERSIONNO,:PRESSPARTMOP,:PRESSPARTCYCLE,:PRESSPARTNEST,:PRESSPARTREVISIONNUMBER,:SUPPLIERADMIN)");
            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,4),
					new OracleParameter(":BDNTPARTNO", OracleType.VarChar,50),
					new OracleParameter(":BDNTPARTNAME", OracleType.VarChar,50),
					new OracleParameter(":BDNTREVISIONNO", OracleType.VarChar,50),
					new OracleParameter(":BDNTREVISIONSTATUS", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERID", OracleType.Number,4),
					new OracleParameter(":CREATETIME", OracleType.DateTime),
					new OracleParameter(":CREATEUSER", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERPARTNO", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERPARTNAME", OracleType.VarChar,50),
					new OracleParameter(":COLOR", OracleType.VarChar,50),
					new OracleParameter(":PLANTID", OracleType.Number,4),
					new OracleParameter(":REASONFORSAMPLING", OracleType.VarChar,50),
					new OracleParameter(":INTTIALSAMPLING", OracleType.VarChar,50),
					new OracleParameter(":OTHERSAMPLES", OracleType.VarChar,50),
					new OracleParameter(":QLEVEL", OracleType.VarChar,50),
					new OracleParameter(":ELEVEL", OracleType.VarChar,50),
					new OracleParameter(":MODIFICATIONSCOPE", OracleType.VarChar,50),
					new OracleParameter(":REMARKS", OracleType.VarChar,500),
					new OracleParameter(":ECUHWVERSIONNO", OracleType.VarChar,50),
					new OracleParameter(":ECUSWVERSIONNO", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTMOP", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTCYCLE", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTNEST", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTREVISIONNUMBER", OracleType.VarChar,50),
                                           new OracleParameter(":SUPPLIERADMIN",OracleType.VarChar,150)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.BDNTPARTNO;
            parameters[2].Value = model.BDNTPARTNAME;
            parameters[3].Value = model.BDNTREVISIONNO;
            parameters[4].Value = model.BDNTREVISIONSTATUS;
            parameters[5].Value = model.SUPPLIERID;
            parameters[6].Value = model.CREATETIME;
            parameters[7].Value = model.CREATEUSER;
            parameters[8].Value = model.SUPPLIERPARTNO;
            parameters[9].Value = model.SUPPLIERPARTNAME;
            parameters[10].Value = model.COLOR;
            parameters[11].Value = model.PLANTID;
            parameters[12].Value = model.REASONFORSAMPLING;
            parameters[13].Value = model.INTTIALSAMPLING;
            parameters[14].Value = model.OTHERSAMPLES;
            parameters[15].Value = model.QLEVEL;
            parameters[16].Value = model.ELEVEL;
            parameters[17].Value = model.MODIFICATIONSCOPE;
            parameters[18].Value = model.REMARKS;
            parameters[19].Value = model.ECUHWVERSIONNO;
            parameters[20].Value = model.ECUSWVERSIONNO;
            parameters[21].Value = model.PRESSPARTMOP;
            parameters[22].Value = model.PRESSPARTCYCLE;
            parameters[23].Value = model.PRESSPARTNEST;
            parameters[24].Value = model.PRESSPARTREVISIONNUMBER;
            parameters[25].Value = model.Supplieradmin;

            return DbHelperOra.ExecuteSql(strSql.ToString(), parameters) > 0 ? int.Parse(model.ID.ToString()) : 0 ;
        }



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddExcel(PART model)
        {
            model.ID = DbHelperOra.GetMaxID("ID", "PART");
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into PART(");
            strSql.Append("ID,BDNTPARTNO,BDNTPARTNAME,BDNTREVISIONNO,BDNTREVISIONSTATUS,SUPPLIERID,CREATETIME,CREATEUSER,COLOR,SUPPLIERADMIN)");
            strSql.Append(" values (");
            strSql.Append(":ID,:BDNTPARTNO,:BDNTPARTNAME,:BDNTREVISIONNO,:BDNTREVISIONSTATUS,:SUPPLIERID,:CREATETIME,:CREATEUSER,:COLOR,:SUPPLIERADMIN)");
            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,4),
					new OracleParameter(":BDNTPARTNO", OracleType.VarChar,50),
					new OracleParameter(":BDNTPARTNAME", OracleType.VarChar,50),
					new OracleParameter(":BDNTREVISIONNO", OracleType.VarChar,50),
					new OracleParameter(":BDNTREVISIONSTATUS", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERID", OracleType.Number,4),
					new OracleParameter(":CREATETIME", OracleType.DateTime),
					new OracleParameter(":CREATEUSER", OracleType.VarChar,50),
					new OracleParameter(":COLOR", OracleType.VarChar,50),
                                           new OracleParameter(":SUPPLIERADMIN",OracleType.VarChar,150)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.BDNTPARTNO;
            parameters[2].Value = model.BDNTPARTNAME;
            parameters[3].Value = model.BDNTREVISIONNO;
            parameters[4].Value = model.BDNTREVISIONSTATUS;
            parameters[5].Value = model.SUPPLIERID;
            parameters[6].Value = model.CREATETIME;
            parameters[7].Value = model.CREATEUSER;
            parameters[8].Value = model.COLOR;
            parameters[9].Value = model.Supplieradmin;

            return DbHelperOra.ExecuteSql(strSql.ToString(), parameters) > 0 ? int.Parse(model.ID.ToString()) : 0;
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(PART model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update PART set ");
            strSql.Append("ID=:ID,");
            strSql.Append("BDNTPARTNO=:BDNTPARTNO,");
            strSql.Append("BDNTPARTNAME=:BDNTPARTNAME,");
            strSql.Append("BDNTREVISIONNO=:BDNTREVISIONNO,");
            strSql.Append("BDNTREVISIONSTATUS=:BDNTREVISIONSTATUS,");
            strSql.Append("SUPPLIERID=:SUPPLIERID,");
            strSql.Append("CREATETIME=:CREATETIME,");
            strSql.Append("CREATEUSER=:CREATEUSER,");
            strSql.Append("SUPPLIERPARTNO=:SUPPLIERPARTNO,");
            strSql.Append("SUPPLIERPARTNAME=:SUPPLIERPARTNAME,");
            strSql.Append("COLOR=:COLOR,");
            strSql.Append("PLANTID=:PLANTID,");
            strSql.Append("REASONFORSAMPLING=:REASONFORSAMPLING,");
            strSql.Append("INTTIALSAMPLING=:INTTIALSAMPLING,");
            strSql.Append("OTHERSAMPLES=:OTHERSAMPLES,");
            strSql.Append("QLEVEL=:QLEVEL,");
            strSql.Append("ELEVEL=:ELEVEL,");
            strSql.Append("MODIFICATIONSCOPE=:MODIFICATIONSCOPE,");
            strSql.Append("REMARKS=:REMARKS,");
            strSql.Append("ECUHWVERSIONNO=:ECUHWVERSIONNO,");
            strSql.Append("ECUSWVERSIONNO=:ECUSWVERSIONNO,");
            strSql.Append("PRESSPARTMOP=:PRESSPARTMOP,");
            strSql.Append("PRESSPARTCYCLE=:PRESSPARTCYCLE,");
            strSql.Append("PRESSPARTNEST=:PRESSPARTNEST,");
            strSql.Append("PRESSPARTREVISIONNUMBER=:PRESSPARTREVISIONNUMBER");
            strSql.Append(" where id="+model.ID);
            OracleParameter[] parameters = {
					new OracleParameter(":ID", OracleType.Number,4),
					new OracleParameter(":BDNTPARTNO", OracleType.VarChar,50),
					new OracleParameter(":BDNTPARTNAME", OracleType.VarChar,50),
					new OracleParameter(":BDNTREVISIONNO", OracleType.VarChar,50),
					new OracleParameter(":BDNTREVISIONSTATUS", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERID", OracleType.Number,4),
					new OracleParameter(":CREATETIME", OracleType.DateTime),
					new OracleParameter(":CREATEUSER", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERPARTNO", OracleType.VarChar,50),
					new OracleParameter(":SUPPLIERPARTNAME", OracleType.VarChar,50),
					new OracleParameter(":COLOR", OracleType.VarChar,50),
					new OracleParameter(":PLANTID", OracleType.Number,4),
					new OracleParameter(":REASONFORSAMPLING", OracleType.VarChar,50),
					new OracleParameter(":INTTIALSAMPLING", OracleType.VarChar,50),
					new OracleParameter(":OTHERSAMPLES", OracleType.VarChar,50),
					new OracleParameter(":QLEVEL", OracleType.VarChar,50),
					new OracleParameter(":ELEVEL", OracleType.VarChar,50),
					new OracleParameter(":MODIFICATIONSCOPE", OracleType.VarChar,50),
					new OracleParameter(":REMARKS", OracleType.VarChar,500),
					new OracleParameter(":ECUHWVERSIONNO", OracleType.VarChar,50),
					new OracleParameter(":ECUSWVERSIONNO", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTMOP", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTCYCLE", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTNEST", OracleType.VarChar,50),
					new OracleParameter(":PRESSPARTREVISIONNUMBER", OracleType.VarChar,50)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.BDNTPARTNO;
            parameters[2].Value = model.BDNTPARTNAME;
            parameters[3].Value = model.BDNTREVISIONNO;
            parameters[4].Value = model.BDNTREVISIONSTATUS;
            parameters[5].Value = model.SUPPLIERID;
            parameters[6].Value = model.CREATETIME;
            parameters[7].Value = model.CREATEUSER;
            parameters[8].Value = model.SUPPLIERPARTNO;
            parameters[9].Value = model.SUPPLIERPARTNAME;
            parameters[10].Value = model.COLOR;
            parameters[11].Value = model.PLANTID;
            parameters[12].Value = model.REASONFORSAMPLING;
            parameters[13].Value = model.INTTIALSAMPLING;
            parameters[14].Value = model.OTHERSAMPLES;
            parameters[15].Value = model.QLEVEL;
            parameters[16].Value = model.ELEVEL;
            parameters[17].Value = model.MODIFICATIONSCOPE;
            parameters[18].Value = model.REMARKS;
            parameters[19].Value = model.ECUHWVERSIONNO;
            parameters[20].Value = model.ECUSWVERSIONNO;
            parameters[21].Value = model.PRESSPARTMOP;
            parameters[22].Value = model.PRESSPARTCYCLE;
            parameters[23].Value = model.PRESSPARTNEST;
            parameters[24].Value = model.PRESSPARTREVISIONNUMBER;

          return  DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public int Delete(int id)
        {
            //该表无主键信息，请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from PART ");
            strSql.Append(" where id="+id);
            OracleParameter[] parameters = {
};

          return  DbHelperOra.ExecuteSql(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PART GetModel(int id)
        {
            //该表无主键信息，请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,BDNTPARTNO,BDNTPARTNAME,BDNTREVISIONNO,BDNTREVISIONSTATUS,SUPPLIERID,CREATETIME,CREATEUSER,SUPPLIERPARTNO,SUPPLIERPARTNAME,COLOR,PLANTID,REASONFORSAMPLING,INTTIALSAMPLING,OTHERSAMPLES,QLEVEL,ELEVEL,MODIFICATIONSCOPE,REMARKS,ECUHWVERSIONNO,ECUSWVERSIONNO,PRESSPARTMOP,PRESSPARTCYCLE,PRESSPARTNEST,PRESSPARTREVISIONNUMBER from PART ");
            strSql.Append(" where id="+id);
            OracleParameter[] parameters = {
};

            PART model = new PART();
            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.BDNTPARTNO = ds.Tables[0].Rows[0]["BDNTPARTNO"].ToString();
                model.BDNTPARTNAME = ds.Tables[0].Rows[0]["BDNTPARTNAME"].ToString();
                model.BDNTREVISIONNO = ds.Tables[0].Rows[0]["BDNTREVISIONNO"].ToString();
                model.BDNTREVISIONSTATUS = ds.Tables[0].Rows[0]["BDNTREVISIONSTATUS"].ToString();
                if (ds.Tables[0].Rows[0]["SUPPLIERID"].ToString() != "")
                {
                    model.SUPPLIERID = int.Parse(ds.Tables[0].Rows[0]["SUPPLIERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CREATETIME"].ToString() != "")
                {
                    model.CREATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATETIME"].ToString());
                }
                model.CREATEUSER = ds.Tables[0].Rows[0]["CREATEUSER"].ToString();
                model.SUPPLIERPARTNO = ds.Tables[0].Rows[0]["SUPPLIERPARTNO"].ToString();
                model.SUPPLIERPARTNAME = ds.Tables[0].Rows[0]["SUPPLIERPARTNAME"].ToString();
                model.COLOR = ds.Tables[0].Rows[0]["COLOR"].ToString();
                if (ds.Tables[0].Rows[0]["PLANTID"].ToString() != "")
                {
                    model.PLANTID = int.Parse(ds.Tables[0].Rows[0]["PLANTID"].ToString());
                }
                model.REASONFORSAMPLING = ds.Tables[0].Rows[0]["REASONFORSAMPLING"].ToString();
                model.INTTIALSAMPLING = ds.Tables[0].Rows[0]["INTTIALSAMPLING"].ToString();
                model.OTHERSAMPLES = ds.Tables[0].Rows[0]["OTHERSAMPLES"].ToString();
                model.QLEVEL = ds.Tables[0].Rows[0]["QLEVEL"].ToString();
                model.ELEVEL = ds.Tables[0].Rows[0]["ELEVEL"].ToString();
                model.MODIFICATIONSCOPE = ds.Tables[0].Rows[0]["MODIFICATIONSCOPE"].ToString();
                model.REMARKS = ds.Tables[0].Rows[0]["REMARKS"].ToString();
                model.ECUHWVERSIONNO = ds.Tables[0].Rows[0]["ECUHWVERSIONNO"].ToString();
                model.ECUSWVERSIONNO = ds.Tables[0].Rows[0]["ECUSWVERSIONNO"].ToString();
                model.PRESSPARTMOP = ds.Tables[0].Rows[0]["PRESSPARTMOP"].ToString();
                model.PRESSPARTCYCLE = ds.Tables[0].Rows[0]["PRESSPARTCYCLE"].ToString();
                model.PRESSPARTNEST = ds.Tables[0].Rows[0]["PRESSPARTNEST"].ToString();
                model.PRESSPARTREVISIONNUMBER = ds.Tables[0].Rows[0]["PRESSPARTREVISIONNUMBER"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 根据PPARid得到一个对象实体
        /// </summary>
        public PART GetModelForPPARid(int id)
        {
            //该表无主键信息，请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,BDNTPARTNO,BDNTPARTNAME,BDNTREVISIONNO,BDNTREVISIONSTATUS,SUPPLIERID,CREATETIME,CREATEUSER,SUPPLIERPARTNO,SUPPLIERPARTNAME,COLOR,PLANTID,REASONFORSAMPLING,INTTIALSAMPLING,OTHERSAMPLES,QLEVEL,ELEVEL,MODIFICATIONSCOPE,REMARKS,ECUHWVERSIONNO,ECUSWVERSIONNO,PRESSPARTMOP,PRESSPARTCYCLE,PRESSPARTNEST,PRESSPARTREVISIONNUMBER from PART ");
            strSql.Append(" where id=(select partid from ppar where id="+id+")");
            OracleParameter[] parameters = {
};

            PART model = new PART();
            DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.BDNTPARTNO = ds.Tables[0].Rows[0]["BDNTPARTNO"].ToString();
                model.BDNTPARTNAME = ds.Tables[0].Rows[0]["BDNTPARTNAME"].ToString();
                model.BDNTREVISIONNO = ds.Tables[0].Rows[0]["BDNTREVISIONNO"].ToString();
                model.BDNTREVISIONSTATUS = ds.Tables[0].Rows[0]["BDNTREVISIONSTATUS"].ToString();
                if (ds.Tables[0].Rows[0]["SUPPLIERID"].ToString() != "")
                {
                    model.SUPPLIERID = int.Parse(ds.Tables[0].Rows[0]["SUPPLIERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CREATETIME"].ToString() != "")
                {
                    model.CREATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATETIME"].ToString());
                }
                model.CREATEUSER = ds.Tables[0].Rows[0]["CREATEUSER"].ToString();
                model.SUPPLIERPARTNO = ds.Tables[0].Rows[0]["SUPPLIERPARTNO"].ToString();
                model.SUPPLIERPARTNAME = ds.Tables[0].Rows[0]["SUPPLIERPARTNAME"].ToString();
                model.COLOR = ds.Tables[0].Rows[0]["COLOR"].ToString();
                if (ds.Tables[0].Rows[0]["PLANTID"].ToString() != "")
                {
                    model.PLANTID = int.Parse(ds.Tables[0].Rows[0]["PLANTID"].ToString());
                }
                model.REASONFORSAMPLING = ds.Tables[0].Rows[0]["REASONFORSAMPLING"].ToString();
                model.INTTIALSAMPLING = ds.Tables[0].Rows[0]["INTTIALSAMPLING"].ToString();
                model.OTHERSAMPLES = ds.Tables[0].Rows[0]["OTHERSAMPLES"].ToString();
                model.QLEVEL = ds.Tables[0].Rows[0]["QLEVEL"].ToString();
                model.ELEVEL = ds.Tables[0].Rows[0]["ELEVEL"].ToString();
                model.MODIFICATIONSCOPE = ds.Tables[0].Rows[0]["MODIFICATIONSCOPE"].ToString();
                model.REMARKS = ds.Tables[0].Rows[0]["REMARKS"].ToString();
                model.ECUHWVERSIONNO = ds.Tables[0].Rows[0]["ECUHWVERSIONNO"].ToString();
                model.ECUSWVERSIONNO = ds.Tables[0].Rows[0]["ECUSWVERSIONNO"].ToString();
                model.PRESSPARTMOP = ds.Tables[0].Rows[0]["PRESSPARTMOP"].ToString();
                model.PRESSPARTCYCLE = ds.Tables[0].Rows[0]["PRESSPARTCYCLE"].ToString();
                model.PRESSPARTNEST = ds.Tables[0].Rows[0]["PRESSPARTNEST"].ToString();
                model.PRESSPARTREVISIONNUMBER = ds.Tables[0].Rows[0]["PRESSPARTREVISIONNUMBER"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select t.*,rownum from (select r.ID,BDNTPARTNO,BDNTPARTNAME,BDNTREVISIONNO,BDNTREVISIONSTATUS,r.SUPPLIERID,CREATETIME,CREATEUSER,SUPPLIERPARTNO,SUPPLIERPARTNAME,COLOR,PLANTID,REASONFORSAMPLING,INTTIALSAMPLING,OTHERSAMPLES,QLEVEL,ELEVEL,MODIFICATIONSCOPE,REMARKS,ECUHWVERSIONNO,ECUSWVERSIONNO,PRESSPARTMOP,PRESSPARTCYCLE,PRESSPARTNEST,PRESSPARTREVISIONNUMBER,t.plantname,r.supplieradmin ");
            strSql.Append(" from part r left join plant t on r.plantid=t.id order by plantid desc)t ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetListByWhere(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select r.ID,BDNTPARTNO,BDNTPARTNAME,BDNTREVISIONNO,BDNTREVISIONSTATUS,SUPPLIERID,CREATETIME,CREATEUSER,SUPPLIERPARTNO,SUPPLIERPARTNAME,COLOR,PLANTID,REASONFORSAMPLING,INTTIALSAMPLING,OTHERSAMPLES,QLEVEL,ELEVEL,MODIFICATIONSCOPE,REMARKS,ECUHWVERSIONNO,ECUSWVERSIONNO,PRESSPARTMOP,PRESSPARTCYCLE,PRESSPARTNEST,PRESSPARTREVISIONNUMBER,rownum,a.pparversion ");
            strSql.Append(" from part r left join ppar a on r.id=a.partid ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOra.Query(strSql.ToString());
        }

        /// <summary>
        /// 分配工厂
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public int PlantAllot(PART part)
        {
            string sql = string.Format("update part set plantid={0} where id={1}",part.PLANTID,part.ID);
            return DbHelperOra.ExecuteSql(sql);
        }
    }
}
